<%-
local rowcnt = 1
function rowstyle()
	rowcnt = rowcnt + 1
	return (rowcnt % 2) + 1
end
-%>

<style type="text/css">
	.center { text-align: center }
	.nowrap { white-space: nowrap }
	.wrap   { word-break: break-all; min-width: 100px }
	.red    { color: #b20000 }
	.green  { color: #00a100 }
	.blue   { color: #0000bf }
	.bold   { font-weight: bold }
	table.cbi-section-table a:link { color: #404040 }
	table.cbi-section-table a:visited { color: #404040 }
</style>

<%+rtorrent/tabmenu%>
<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
	<div class="cbi-section-descr"><%=self.description%></div>
	<div class="cbi-section-node">
		<table class="cbi-section-table">
			<tr class="cbi-section-table-titles">
			<%- for i, k in pairs(self.children) do -%>
				<th class="cbi-section-table-cell<% if i ~= (self.headcol or 1) then %> center nowrap<% else %> wrap<% end -%>
				"<%=ifattr(k.hint, "title", k.hint)%><%=ifattr(k.onclick, "onclick", k.onclick)%>><%=k.title%></th>
			<%- end -%>
			</tr>

			<%- for j, k in ipairs(self:cfgsections()) do
				section = k
				scope = { valueheader = "rtorrent/empty", valuefooter = "rtorrent/empty" }
			-%>
				<tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>" id="cbi-<%=self.config%>-<%=section%>">
				<%- for i, node in ipairs(self.children) do -%>
					<td class="cbi-value-field<% if i ~= (self.headcol or 1) then %> center nowrap<% else %> wrap
					<%- end if j > 1 and j == table.getn(self:cfgsections()) then %> bold<% end %>">
						<div id="cbi-<%=node.config.."-"..section.."-"..node.option%>">
							<%- node:render(section, scope or {}) -%>
						</div>
						<div id="cbip-<%=node.config.."-"..section.."-"..node.option%>"></div>
					</td>
				<%- end -%>
				</tr>
			<%- end -%>
		</table>
	</div>
</fieldset>
